package com.ye.common.utils;

import java.util.Random;

/**
 * @Auther: baby
 * @Date: 2023/10/10 00:25
 * @Description:
 */
public class GenerateRandom {


    public static final String CHARACTERS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
    public static final int USERNAME_LENGTH = 8;

    public static String generateRandomString(int length) {
        Random random = new Random();
        StringBuilder sb = new StringBuilder(length);
        for (int i = 0; i < length; i++) {
            int index = random.nextInt(CHARACTERS.length());
            sb.append(CHARACTERS.charAt(index));
        }
        return sb.toString();
    }
}
